#ifndef _APPS_BDESKTOP_CCLIENT_H_
#define _APPS_BDESKTOP_CCLIENT_H_

#include "auto.h"
#include <buola/gui/x11/cx11dispatcher.h>
#include <buola/gui/x11/cx11window.h>

#include <buola/utility/usignal.h>

namespace buola { namespace bdesktop {

class CClient : public gui::x11::CX11EventFilter
{
public:
    CClient();
    virtual ~CClient();

    bool Create(Window);

    bool ShouldBeInTaskBar();
    bool ShouldBeInPager();

    void WMActivate();

protected:
    void WMSendMessage(Atom, long);

protected:
    void SetTBFlags(ETBFlags pTBFlags)            {   mTBFlags=pTBFlags;      }
    ETBFlags GetTBFlags()                         {   return mTBFlags;        }

    void SetTBFlag(ETBFlags pFlag)                {   mTBFlags|=pFlag;        }
    void UnsetTBFlag(ETBFlags pFlag)              {   mTBFlags&=(~pFlag);     }

public:
    bool GetTBFlag(ETBFlags pFlag)        {   return ((mTBFlags&pFlag)==pFlag);   }
    int GetTBType()                     {   return mTBType;         }
    unsigned int GetTBDesktop()         {   return mTBDesktop;          }
    PImage GetTBIcon(const CSize&);
    CPoint GetTBPos()                   {   return mTBPos;              }
    CSize GetTBSize()                   {   return mTBSize;             }

    TID GetID()                         {   return mWindow->GetID();    }

    void GetClientGeometry();
    void ReadState();

//Events
    bool OnX11Event(XEvent*);

    void DoProperty(XPropertyEvent*);
    void OnMove(gui::CGeometryEvent*);
    void OnSize(gui::CGeometryEvent*);

    USignal<void()> sRemoved;

protected:
    ETBFlags mTBFlags;
    int mTBType;        //dock,desktop...
    unsigned int mTBDesktop;
    std::vector<PImage> mTBIcons;
    gui::PIcon mTBIcon;
    CPoint mTBPos;
    CSize mTBSize;

public:
    std::wstring mName;
    std::wstring mIconName;
    std::string mApplicationName;
    std::string mApplicationClass;

    gui::x11::CX11Window *mWindow;
};

/*namespace bdesktop*/ } /*namespace buola*/ }

#endif
